package components.scenes;

import java.awt.Color;
import java.awt.Font;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.GameComponent;
import com.uqbar.vainilla.GameScene;
import com.uqbar.vainilla.appearances.Appearance;
import com.uqbar.vainilla.appearances.Label;
import com.uqbar.vainilla.appearances.Rectangle;
import com.uqbar.vainilla.events.constants.Key;
import components.decoration.Background;

public abstract class PresentationScene extends GameScene {

	private int width;
	private int height;
	
	public PresentationScene(String gameTitle, Font font, Color color, int aWidth, int aHeight){
		this.width = aWidth;
		this.height = aHeight;
		this.addBackground(aWidth, aHeight);
		this.addTitleLabel(gameTitle, font, color);
		this.addButtonLabel();
	}

	private void addBackground(int width, int height) {
		this.addComponent(new Background(new Rectangle(Color.BLACK, width, height)));
	}

	private void addButtonLabel() {
		GameComponent gc = new GameComponent(){
			public void update(DeltaState delta){
				super.update(delta);
				if (delta.isKeyPressed(Key.ENTER)){
					this.getGame().setCurrentScene(getFirstScene());
				}
			}

		};
		gc.setX(this.width/2 - 200);
		gc.setY(this.height/2 +200);
		gc.setZ(1);
		gc.setAppearance(new Label(new Font(Font.SERIF, Font.PLAIN, 20), Color.WHITE, "Press enter to start"));
		this.addComponent(gc);
		
	}

	protected abstract GameScene getFirstScene();
	private void addTitleLabel(String gameTitle, Font font, Color color) {
		GameComponent gc = new GameComponent();
		gc.setX(this.width/2 - 100);
		gc.setY(this.height/2 - 200);
		gc.setZ(1);
		gc.setAppearance(new Label(font, color, gameTitle));
		this.addComponent(gc);
		
	}
}
